// 部分样式来源于其他开源UI库

@import './vars';

@toolBarHeight: 35px;
@toolBarPadding: 4px;

.@{prefix} {
  .css-vars(false);

  width: 100%;
  height: 425px;
  position: relative;
  box-sizing: border-box;
  border: 1px solid var(--md-border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--md-bk-color);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI',
    system-ui, ui-sans-serif, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
    'Segoe UI Emoji';

  /* 浏览器滚动条 */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-corner,
  ::-webkit-scrollbar-track {
    background-color: var(--md-scrollbar-bg-color);
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 2px;
    background-color: var(--md-scrollbar-thumb-color);
  }

  ::-webkit-scrollbar-button:vertical {
    display: none;
  }

  ::-webkit-scrollbar-thumb:vertical:hover {
    background-color: var(--md-scrollbar-thumb-hover-color);
  }

  ::-webkit-scrollbar-thumb:vertical:active {
    background-color: var(--md-scrollbar-thumb-avtive-color);
  }

  &-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    overflow: hidden;
  }

  &-menu {
    margin: 0;
    padding: 0;
    border-radius: 3px;
    border: 1px solid var(--md-border-color);
    background-color: inherit;

    &-item {
      list-style: none;
      font-size: 12px;
      color: var(--md-color);
      padding: 4px 10px;
      cursor: pointer;
      line-height: 16px;

      &:first-of-type {
        padding-top: 8px;
      }

      &:last-of-type {
        padding-bottom: 8px;
      }

      &:hover {
        background-color: var(--md-bk-hover-color);
      }
    }
  }

  &-table-shape {
    padding: 4px;
    border-radius: 3px;
    border: 1px solid var(--md-border-color);
    display: flex;
    flex-direction: column;

    &-row {
      display: flex;
    }

    &-col {
      padding: 2px;
      cursor: pointer;

      &-default {
        width: 16px;
        height: 16px;
        background-color: #e0e0e0;
        border-radius: 3px;
        transition: all 0.2s;
      }

      &-include {
        background-color: #aaa;
      }
    }
  }

  &-toolbar-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    height: @toolBarHeight;
    flex-shrink: 0;
    padding: @toolBarPadding;
    border-bottom: 1px solid var(--md-border-color);

    &::-webkit-scrollbar {
      height: 0 !important;
    }

    .@{prefix}-toolbar {
      min-width: 850px;
      height: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-sizing: content-box;

      &-item {
        height: 24px;
        display: inline-block;
        padding: 0 4px;
        transition: all 0.3s;
        border-radius: 0;
        cursor: pointer;
        list-style: none;
        user-select: none;

        &:hover {
          border-radius: 3px;
          background-color: var(--md-bk-color-outstand);
        }
      }

      &-left,
      &-right {
        padding: 1px 0;
        display: flex;
        align-items: center;
      }
    }
  }

  &-content {
    display: flex;
    // height: calc(100% - @toolBarHeight - 2 * @toolBarPadding - 1px);
    flex: 1;
    height: 0;
    flex-shrink: 0;

    .@{prefix}-input-wrapper {
      flex: 1;
      box-sizing: border-box;

      textarea {
        width: 100%;
        height: 100%;
        padding: 10px 20px;
        box-sizing: border-box;
        font-size: 1em;
        font-family: -apple-system, Consolas, BlinkMacSystemFont, 'Segoe UI', Helvetica,
          Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
        resize: none;
        border: none;
        outline: none;
        overflow-y: scroll;
        color: inherit;
        background-color: inherit;
        line-height: 1.4;
      }

      textarea.textarea-only {
        overflow-y: auto;
      }
    }

    .@{prefix}-preview-wrapper {
      position: relative;
      flex: 1;
      box-sizing: border-box;
      overflow: auto;
    }

    .@{prefix}-preview,
    .@{prefix}-html {
      padding: 10px 20px;
      font-size: 16px;
      position: relative;
      word-break: break-all;
    }
  }

  &-footer {
    height: 24px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--md-color);
    border-top: 1px solid var(--md-border-color);
    display: flex;
    justify-content: space-between;

    &-item {
      display: inline-flex;
      align-items: center;
      height: 100%;
      padding: 0 10px;
    }

    &-label {
      padding-right: 5px;
      line-height: 1;
    }
  }

  &-form-item {
    margin-bottom: 14px;
    text-align: center;

    &:last-of-type {
      margin-bottom: 0;
    }
  }

  &-lable {
    font-size: 14px;
    color: var(--md-color);
    width: 80px;
    text-align: center;
    display: inline-block;
  }

  &-input {
    border-radius: 4px;
    padding: 4px 11px;
    color: var(--md-color);
    font-size: 14px;
    line-height: 1.5715;
    background-color: var(--md-bk-color);
    background-image: none;
    border: 1px solid var(--md-border-color);
    transition: all 0.2s;

    &:focus,
    &:hover {
      border-color: var(--md-border-hover-color);
      outline: 0;
    }

    &:focus {
      border-color: var(--md-border-active-color);
    }
  }

  &-btn {
    font-weight: 400;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid var(--md-border-color);
    white-space: nowrap;
    user-select: none;
    height: 32px;
    padding: 0 15px;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s linear;
    color: var(--md-color);
    background-color: var(--md-bk-color);
    border-color: var(--md-border-color);
    margin-left: 10px;

    &:first-of-type {
      margin-left: 0;
    }

    &:hover {
      color: var(--md-hover-color);
      background-color: var(--md-bk-color);
      border-color: var(--md-border-hover-color);
    }

    &-row {
      width: 100%;
    }
  }

  &-katex-block {
    text-align: center;
    margin: 20px;
  }
}

.@{prefix}-previewOnly {
  border: none;
  height: auto;

  .@{prefix}-content {
    height: 100%;
  }

  .@{prefix}-preview {
    padding: 0;
  }
}

.@{prefix}-dark {
  .css-vars(true);

  .@{prefix}-table-shape {
    &-col {
      &-default {
        background-color: #222;
      }

      &-include {
        background-color: #555;
      }
    }
  }
}

.@{prefix}-fullscreen {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto !important;
  height: auto !important;
  z-index: 10000;
}

.mermaid,
.@{prefix}-katex-inline,
.@{prefix}-katex-block {
  display: none;
}

.mermaid[data-processed],
.@{prefix}-katex-inline[data-processed] {
  display: initial;
}

.@{prefix}-katex-block[data-processed] {
  display: block;
}

// 图片预览优先级高于编辑器，低于编辑器弹窗
.medium-zoom-overlay,
.medium-zoom-image--opened {
  z-index: 100001;
}
